package news;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.util.Log;

public class News implements Serializable {
	
	private static final long serialVersionUID = 7608709565882860286L;
	
	private String author;
	private String message;
	private String date;
	private Date dateAsType;
	
	public News(String date, String author, String message){
		this.date = date;
		this.author = author;
		this.message = message;
	}
	
	public void setAuthor(String author) {
		this.author = author;
	}
	
	public String getAuthor() {
		return author;
	}
	
	public void setMessage(String message) {
		this.message = message;
	}
	
	public String getMessage() {
		return message;
	}
	
	public void setDate(String date) {
		SetDateAsType(date);
		this.date = date;
	}
		
	public String getDate() {
		return date;
	}
	
	public Date getDateAsType() {
		return dateAsType == null ? new Date() : dateAsType;
	}

	private void SetDateAsType(String date) {
			
		try {			
		DateFormat formatter; 		 			
		formatter = new SimpleDateFormat("dd.MMM.yy");		 			
		dateAsType = (Date)formatter.parse(date); 		
		}
		catch(ParseException e) {			
			Log.d("badresden app", e.toString());		
		}
	}
}
